Skip to content

fix: keep ordinary fields that share a name with a secret - #172

Closed
ChiragAgg5k wants to merge 1 commit into
mainfrom
fix/secret-names-unambiguous
Closed

ChiragAgg5k wants to merge 1 commit into
mainfrom
fix/secret-names-unambiguous

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What does this PR do?

Follow-up to #170, the same fix as appwrite/sdk-generator#2222 for the CLI.

When the SDK can't parse a response, the error returns the raw payload, and #170 redacts it by field name: every name an appwrite_console model marks format: password. That set includes code, from MFAChallengeSecret.code, the one-time MFA code. So an unparsed country, language or locale payload would have its ordinary code hidden.

_secret_names now leaves out any name that is also a non-secret string (or a list or optional of one) on another SDK model. Against appwrite-console 0.16.0, that drops only code. The other 30 names stay, including secret, password and uri.

Typed results aren't affected: they're redacted per model field, so MFAChallengeSecret.code is still redacted there.

Test Plan

  • Extended test_format_appwrite_error_returns_the_unhydrated_payload with an unparsed country payload; "code": "DE" comes back untouched.
  • ruff, black --check and pyright (0 errors) pass.
  • Unit and e2e suites pass.

The parse-error fallback redacts by field name. 'code' is the MFA challenge code but also a country's or language's code, so it hid those too. Leave out names that are ordinary strings on another model, as the CLI now does (appwrite/sdk-generator#2222).
@appwrite

appwrite Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🟡 Tier B · Needs changes before merging

An SDK parse failure on an MFA response can now expose its one-time code in the raw error payload.

This change excludes SDK field names that also appear as ordinary string fields from name-based redaction of unparsed responses. It adds a country-code regression case to the Appwrite error-formatting test.

Verdict New comments Fixed Still open
🛑 Changes requested 1 0 0
Finding Where
🟠 Keep MFA code redacted in untyped responses src/mcp_server_appwrite/redaction.py:131
Fix with agent prompt
### Issue 1
src/mcp_server_appwrite/redaction.py:131
**Keep MFA `code` redacted in untyped responses**

`_format_response_parse_error` uses `redact_payload` for every unhydrated response, so removing `code` here disables its masking globally, not just for Country. If an MFA challenge response fails SDK hydration, its password-formatted one-time code is serialized verbatim into the MCP error result and may be retained in the conversation transcript.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
📂 Walkthrough · 2
File Change
src/mcp_server_appwrite/redaction.py Collects ordinary text field names and subtracts them from the secret-name set.
tests/unit/test_server.py Checks that an unparsed country payload retains its ordinary code.

Reviewed 0a8a4b9 · Details · Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Tier B · 1 blocking finding to address. Summary

secret.add(field.alias or name)
elif _text(field.annotation):
plain.add(field.alias or name)
return frozenset(secret - plain)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep MFA code redacted in untyped responses

_format_response_parse_error uses redact_payload for every unhydrated response, so removing code here disables its masking globally, not just for Country. If an MFA challenge response fails SDK hydration, its password-formatted one-time code is serialized verbatim into the MCP error result and may be retained in the conversation transcript.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/mcp_server_appwrite/redaction.py
Line: 131

Comment:
**Keep MFA `code` redacted in untyped responses**

`_format_response_parse_error` uses `redact_payload` for every unhydrated response, so removing `code` here disables its masking globally, not just for Country. If an MFA challenge response fails SDK hydration, its password-formatted one-time code is serialized verbatim into the MCP error result and may be retained in the conversation transcript.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟠 Major · security · Reply if this doesn't apply.

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

Closing: the review is right. The by-name fallback only runs when the SDK can't parse a response, and over-masking a country's code there is harmless, while leaking an MFA challenge code isn't. #170's behaviour (redact every name any model marks secret) is the safer trade-off for that rare path. The CLI case (appwrite/sdk-generator#2222) differs: it redacts every normal response by name, so it has to leave code alone.

@ChiragAgg5k
ChiragAgg5k deleted the fix/secret-names-unambiguous branch November 12, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant